class Solution {
public:
    int missingNumber(vector<int>& nums) {
        int n = nums.size();
        int l = 0,r = n-1;
        while(l <= r){
            int m = (l + r) / 2;
            if(m % 2 == nums[m] % 2){
                l = m + 1;
            }else{
                r = m - 1;
            }
        }
        return l;
    }
};
